﻿using AnesSystem.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem.Controls
{
    /// <summary>
    /// AnesTemplate.xaml 的交互逻辑
    /// </summary>
    public partial class LaborTemplateCtrl : UserControl
    {
        public LaborTemplateCtrl()
        {
            InitializeComponent();
            _scdqsj.IsChecked = true;
            _gr.IsChecked = true;
            this.DataContext = LaborTemplateCtrlViewModel.Instance;
        }


        private void del_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBoxCommon.ShowDialog("确定要此条模板?", MessageBoxCommon.OKCANCLE).Value == true)
            {
                LaborTemplateCtrlViewModel.Instance.DelAnesTemplate();
            }
            else
            {
                return;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if ((bool)_scdqsj.IsChecked)
            {
                LaborTemplateCtrlViewModel.Instance.ApplySelectTemplate(true);
            }
            if ((bool)_zjsj.IsChecked)
            {
                LaborTemplateCtrlViewModel.Instance.ApplySelectTemplate(false);
            }
            DrugAndEventWindow.Instance.CloseWin(false);
        }

        private void RadioButton_Click(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = sender as RadioButton;
            string tag = radioButton.Tag.ToString();
            if (string.IsNullOrEmpty(tag))
            {
                return;
            }

            if ((bool)radioButton.IsChecked)
            {
                LaborTemplateCtrlViewModel.Instance.ChangeDisPlayList(tag);
            }
        }
    }
}
